/*
 * Copyright (C) 2012 by Hao Hou<ghost89413@gmail.com>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>*
 */
//Load user config file for vine
#ifndef __USERCONF_H__
#define __USERCONF_H__
#include <log.h>
typedef enum 
{
	Integer,
	String
} ConfTypeDescriptor;
typedef struct _UserConfigure UserConfigure;
UserConfigure* CreateConfig();  //Create a user conf handler

int ParseConfig(UserConfigure* conf, const char* filename); //parse conf file, if succeed return 0

void* FetchValue( UserConfigure* conf,
	       	  ConfTypeDescriptor type, 
		  void* p, void* def, 
		  const char* key); //fetch an config, return NULL when failed

void* FetchValueEx( UserConfigure* conf,
		    ConfTypeDescriptor type,
		    void* p, void* def,
		    const char* key_template, ...);//fetch an config,use key_template rather than key
int  SetValue( UserConfigure* conf, ConfTypeDescriptor type,
	       const char* key, void* p);
int  SetValueEx(UserConfigure* conf, ConfTypeDescriptor type,
		const char* key_template, void* p, ...);
void DestoryConf(UserConfigure* conf);  //free all resource for conf
#endif
